/**
 * 2011-11-16下午4:23:49
 */
package dao;

import java.sql.SQLException;

import util.MysqlConn;

/**
 * @author Baicai 修改商品信息
 */
public class UpdateGoods {

	/**
	 * 修改商品信息的方法
	 * 
	 * @param id
	 * @param name
	 * @param sort
	 * @param price
	 * @param picture
	 * @param information
	 * @return boolean
	 */
	public static boolean updateGoods(int id, String name, String sort,
			String price, String picture, String information) {

		float prices = Float.parseFloat(price);// 将字符串转变成浮点数
		String string = "update goods set goods_name='" + name
				+ "',goods_sort='" + sort + "',goods_price=" + prices
				+ ",goods_picture='" + picture + "',goods_information='"
				+ information + "' where goods_id=" + id;// 连接sql语句
		MysqlConn.setSqlString(string);
		try {
			int flag = MysqlConn.updateDB();// 执行
			if (flag == 1)// 判断影响行数
				return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			MysqlConn.free();
		}
		return false;
	}
}
